import request from '@/utils/request'
// 登录
export function login(account, password) {
    const data = {
      account,
      password
    }
    return request({
      url: `/cms/login`,
      method: 'post',
      data
    })
  }
  // 登出
  export function logout() {
    return request({
      url: `/auth/logout?loginDevice=QINGJIAO_CLOUD`,
      method: 'post',
    })
  }
  // 用户注册
  export function userRegister(data) {
    return request({
      method: 'post',
      url: '/user/register',
      data
    })
  }
  // 实时余额
  export function getRealtimeBalance() {
    return request({
      method: 'get',
      url: '/user/getRealtimeBalanceAndPoints',
    })
  }
  // 获取所有用户
  export function userList(data) {
    return request({
      method: 'post',
      url: '/user/query',
      data
    })
  }
  // 根据账号获取邮箱
  export function getEmailByAccount(account) {
    return request({
      method: 'get',
      url: `/user/getEmailByAccount?account=${account}`,
    })
  }
  // 发送临时密码
  export function sendTemporaryPassword(data) {
    return request({
      method: 'post',
      url: `/auth/sendCaptchaByEmail`,
      data
    })
  }
  // 通过验证码修改密码
  export function modifyPasswordByCaptcha(data) {
    return request({
      method: 'post',
      url: `/user/modifyPasswordByCaptcha`,
      data
    })
  }
  // 修改虚拟账号密码
  export function modifyPassword(data) {
    return request({
      method: 'post',
      url: `/user/modifyPassword`,
      data
    })
  }
  // 账号充值
  export function payment(data) {
    return request({
      method: 'post',
      url: `/user/payment/native/recharge`,
      data:{
        totalFee:data.totalFee
      },
      headers:{
        'scene-token':data.senceToken
      }
    })
  }
  // 获取未支付订单二维码
  export function paymentCode(id) {
    return request({
      method: 'get',
      url: `/user/payment/code?id=${id}`,
    })
  }
  // 取消订单
  export function cancelpayment(id) {
    return request({
      method: 'get',
      url: `/user/payment/cancel?id=${id}`,
    })
  }
  
  // 检查支付是否成功
  export function checkTradeResult(id) {
    return request({
      method: 'get',
      url: `/user/payment/checkTradeResult?id=${id}`,
    })
  }
// 充值记录
export function tradeQuery(data) {
  return request({
    method: 'post',
    url: `/user/payment/trade/query`,
    data
  })
}
// 账号详情
export function userDetail(id) {
  return request({
    method: 'get',
    url: `/user/details?id=${id}`,
  })
}
// 消费记录列表
export function useRecordList(data) {
  return request({
    method: 'post',
    url: `/manager/useRecord/list`,
    data
  })
}

// 在线用户列表
export function useRecordOnline(data) {
  return request({
    method: 'post',
    url: `/manager/useRecord/online`,
    data
  })
}


// 编辑用户信息
export function improveUserInfo(data) {
  return request({
    method: 'post',
    url: `/user/improveUserInfo`,
    data
  })
}
// 获取场景token
export function sceneToken() {
  return request({
    method: 'get',
    url: `/auth/token?scene=recharge`,
  })
}

// 退款
export function refundPay(id) {
  return request({
    method: 'get',
    url: `/user/payment/refund?id=${id}`,
  })
}

// 设备列表
export function shebeilist(data) {
  return request({
    method: 'post',
    url: `/manager/virtual/list`,
    data
  })
}
// 重启设备
export function restartvirtual(id) {
  return request({
    method: 'get',
    url: `/manager/virtual/restart/${id}`,
  })
}
// 启动设备
export function openvirtual(id) {
  return request({
    method: 'get',
    url: `/manager/virtual/open/${id}`,
  })
}

// 修改用户余额
export function modifybalance(data) {
  return request({
    method: 'post',
    url: `/user/modify-points`,
    data
  })
}
// 获取可用优惠
export function getApplicableIncentives() {
  return request({
    method: 'get',
    url: `/user/getApplicableIncentives`,
  })
}
// 获取已存在优惠的网吧
export function getUsingTargets() {
  return request({
    method: 'get',
    url: `/user/incentive/getUsingTargets`,
  })
}
// 删除用户
export function userDelete(data) {
  return request({
    method: 'delete',
    url: `/user/delete`,
    data
  })
}
